package cn.edu.zpark.security.springmvc.init;

import cn.edu.zpark.security.springmvc.config.ApplicationConfig;
import cn.edu.zpark.security.springmvc.config.WebConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * @PackageName: cn.edu.zpark.security.springmvc.init
 * @ClassName: SpringApplicationInitializer
 * @Description:
 * @author: RZS
 * @date: 2021/7/20  10:42
 */
public class SpringApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    // 加载Spring容器，相当于以前的加载applicationContext.xml文件。
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[] { ApplicationConfig.class  };// 指定rootContext的配置类
    }

    // 加载servletContext，相当于以前的加载springmvc.xml文件
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[] { WebConfig.class }; //指定servletContext的配置类
    }

    // 加载url-mapping
    @Override
    protected String[] getServletMappings() {
        return new String [] {"/"};
    }
}
